﻿using System;
using System.ComponentModel;
using System.Data;
using ReflectionStudio.Core.Events;
using System.Windows;
namespace WPFExcelReport
{
    /// <summary>
    /// Interaction logic for EditEventWindow.xaml
    /// </summary>
    public partial class UIWDECK : ViewBase
    {
      
        public UIWDECK()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
        }

        public override void Window_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            if (IsLoaded)
                return;
            if (app.company=="UBT")
            {
                IsVKPaid = false;
            }
            else
            {
                IsVKPaid = true;
            }          
            base.Window_Loaded(sender, e);
        }

        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);
            dwWD = dwMaster;
            if (dwMaster == null)
            {
                RULEKEY = "";
                KEY = "";
                PRART = ""; 
                IsABKGenerated = false;
            }
            else
            {
                IsABKGenerated = false;
                ARTST = TMV.dwMaster["WDWAKZ"].ToString();
                KEY = dwMaster["WDSA"].ToString() + dwMaster["WDAUFKRS"].ToString() + dwMaster["WDAUFLFD"].ToString() + dwMaster["WDAUFPOS"].ToString() + dwMaster["WDUPOS"].ToString();
                PRART = dwMaster["WDWAKZ"].ToString() + dwMaster["WDART"].ToString() + dwMaster["WDVAR"].ToString()
                    + dwMaster["WDFARBE"].ToString() + dwMaster["WDBESCHICH"].ToString()
                     + dwMaster["WDDESS"].ToString() + dwMaster["WDCOLORIT"].ToString()
                    +KEY;
                if (TMV.WDRESERV > 0)
                    IsABKGenerated = true;
            }
        }




        public void WDLOAD(MessageInfo msg)
        {
            AUFART = msg.AUFTYP;
            string WDTYP = "B";
            if (AUFART == "K")
            {
                WDTYP = "B";
            }
            DataRow dwData = TBMain.NewRow();
            dwData["WDMANDANT"] = app.Mandant;
            dwData["WDAUFKRS"] = msg.KRS;
            dwData["WDAUFLFD"] = msg.LFD;
            dwData["WDAUFPOS"] = msg.POS;
            dwData["WDSA"] = msg.AUFTYP;
            dwData["WDTYP"] = WDTYP;
            DataSet SResult = TMV.QueryWDECK(dwData, 23);
            foreach (DataRow row in SResult.Tables[0].Rows)
            {
                row["WDBEDARF"] = msg.P1;
                row["WDZUGET"] = msg.P3;
            }
            MergeData(SResult, true);
        }


        public void Update(MessageInfo msg)
        {

            dwWD["WDBEDARF"] = msg.P1;
            dwWD["WDART"] = msg.ART;
            dwWD["WDDESS"] = msg.DESS; ;
            dwWD["WDCOLORIT"] = msg.COLORIT;
            dwWD["WDFARBE"] = msg.FARBE; ;
            dwWD["WDBESCHICH"] = msg.BESCHICH; ;
            dwWD["WDVAR"] = msg.VAR;
            dwWD["WDDAT"] = msg.P2;
            TMV.UpdateWDECK(dwWD, app.company, 0);
        }

        public override void LOADBYAUF()
        {
            if (!IsCanLoad)
                return;
            base.LOADBYAUF();
            TBMain.Clear();
            if (ORDERNUM.Length < 12)
                return;
            AUFART = ORDERNUM.Substring(0, 1); ;
            string WDTYP = "B";
            if (AUFART == "K")
            {
                WDTYP = "B";
            }
            dwData = TBMain.NewRow();
            dwData["WDMANDANT"] = app.Mandant;
            dwData["WDAUFKRS"] = ORDERNUM.Substring(1, 2);
            dwData["WDAUFLFD"] = ORDERNUM.Substring(3, 6);
            dwData["WDAUFPOS"] = ORDERNUM.Substring(9, 3);
            dwData["WDSA"] = AUFART;
            dwData["WDTYP"] = WDTYP;
            SResult = TMV.QWD23(dwData);
            MergeData(SResult, true);
        }

        public virtual void OnAUFARTChg(string value)
        { }

        public virtual void OnPRARTChg(string value)
        { }
        public virtual void OnVKKChg(string value)
        {
        }

        public void OrderCommand(object sender, RoutedEventArgs e)
        {

            VICC_WFEVENTS.SVWF.WD02(RUNID, KEY);

        }
        public virtual void OnShowABChg(bool _IsShowAB)
        {
            if (!_IsShowAB)
                return;
            string key = KEY;
            KEY = "";
            KEY = key;
            key = PRART;
            PRART = "";
            PRART = key;

        }
    }
    public partial class UIWDECK
    {
        public VWDECK TMV
        {
            get
            {
                return (VWDECK)MV;
            }
        }
        #region ==IsOnBundleMode===========
        public static readonly DependencyProperty IsOnBundleModeProperty = DependencyProperty.Register("IsOnBundleMode",
        typeof(bool), typeof(UIWDECK),
        new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsOnBundleModeChanged));
        public bool IsOnBundleMode
        {
            get
            {
                return (bool)GetValue(IsOnBundleModeProperty);
            }
            set
            {
                SetValue(IsOnBundleModeProperty, value);
                
            }
        }
        private static void OnIsOnBundleModeChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWDECK;
            if (src != null)
            {
                src.IsOnBundleMode = (bool)e.NewValue;
                src.OnBundleModeChg((bool)e.NewValue);
            }
        }
        public virtual void OnBundleModeChg(bool _IsShowAB)
        {
            if (!_IsShowAB)
                return;
            string key = KEY;
            KEY = "";
            KEY = key;
            key = PRART;
            PRART = "";
            PRART = key;

        }
        #endregion

        #region ==IsShowAB===========
        public static readonly DependencyProperty IsShowABProperty = DependencyProperty.Register("IsShowAB",
        typeof(bool), typeof(UIWDECK),
        new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsShowABChanged));
        public bool IsShowAB
        {
            get
            {
                return (bool)GetValue(IsShowABProperty);
            }
            set
            {
                SetValue(IsShowABProperty, value);
                
            }
        }
        private static void OnIsShowABChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWDECK;
            if (src != null)
            {
                src.IsShowAB = (bool)e.NewValue;
                src.OnShowABChg((bool)e.NewValue);
            }
        }
        #endregion

        #region ==IsInsertManually===========
        public static readonly DependencyProperty IsInsertManuallyProperty = DependencyProperty.Register("IsInsertManually",
            typeof(bool), typeof(UIWDECK),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsInsertManuallyChanged));
        public bool IsInsertManually
        {
            get
            {
                return (bool)GetValue(IsInsertManuallyProperty);
            }
            set
            {
                SetValue(IsInsertManuallyProperty, value);
            }
        }
        private static void OnIsInsertManuallyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWDECK;
            if (src != null)
            {
                src.IsInsertManually = (bool)e.NewValue;
            }
        }
        #endregion

        #region ==dwVF===========
        public static readonly DependencyProperty dwVFProperty = DependencyProperty.Register("dwVF",
        typeof(DataRow), typeof(UIWDECK),
        new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OndwVFChanged));
        public DataRow dwVF
        {
            get
            {
                return (DataRow)GetValue(dwVFProperty);
            }
            set
            {
                SetValue(dwVFProperty, value);
               
            }
        }
        private static void OndwVFChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWDECK;
            if (src != null)
            {
                src.dwVF = (DataRow)e.NewValue;
                src.OnVAFChg((DataRow)e.NewValue);
            }
        }
        public virtual void OnVAFChg(DataRow _dwVF)
        {

        }
        #endregion

        #region ==dwWS===========
        public static readonly DependencyProperty dwWSProperty = DependencyProperty.Register("dwWS",
        typeof(DataRow), typeof(UIWDECK),
        new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OndwWSChanged));
        public DataRow dwWS
        {
            get
            {
                return (DataRow)GetValue(dwWSProperty);
            }
            set
            {
                SetValue(dwWSProperty, value);
                

            }
        }
        private static void OndwWSChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWDECK;
            if (src != null)
            {
                src.dwWS = (DataRow)e.NewValue;
                src.OnWSChg((DataRow)e.NewValue);
            }
        }
        public virtual void OnWSChg(DataRow ws)
        {

        }
        #endregion
        #region ==FLOW===========
        public static readonly DependencyProperty FLOWProperty = DependencyProperty.Register("FLOW",
        typeof(string), typeof(UIWDECK),
        new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnFLOWChanged));
        public string FLOW
        {
            get
            {
                return (string)GetValue(FLOWProperty);
            }
            set
            {
                SetValue(FLOWProperty, value);

            }
        }
        private static void OnFLOWChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWDECK;
            if (src != null)
            {
                src.FLOW = (string)e.NewValue;
                src.OnFLOWChg((string)e.NewValue);
            }
        }
        public virtual void OnFLOWChg(string value)
        {
             
        }
        #endregion
        #region ==IsABKGenerated===========
        public static readonly DependencyProperty IsABKGeneratedProperty = DependencyProperty.Register("IsABKGenerated",
            typeof(bool), typeof(UIWDECK),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OIsABKGeneratedChanged));
        public bool IsABKGenerated
        {
            get
            {
                return (bool)GetValue(IsABKGeneratedProperty);
            }
            set
            {
                SetValue(IsABKGeneratedProperty, value);
            }
        }
        private static void OIsABKGeneratedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWDECK;
            if (src != null)
            {
                bool row = (bool)e.NewValue;
                src.IsABKGenerated = row;
            }
        }
        #endregion

        #region ==ABAUF===========
        public static readonly DependencyProperty ABAUFProperty = DependencyProperty.Register("ABAUF",
            typeof(string), typeof(UIWDECK),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnABAUFChanged));
        public string ABAUF
        {
            get
            {
                return (string)GetValue(ABAUFProperty);
            }
            set
            {
                SetValue(ABAUFProperty, value);
            }
        }
        private static void OnABAUFChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWDECK;
            if (src != null)
            {
                src.ABAUF = (string)e.NewValue;
            }
        }
        #endregion

        #region ==dwMU===========
        public static readonly DependencyProperty dwMUProperty = DependencyProperty.Register("dwMU",
            typeof(DataRow), typeof(UIWDECK),
            new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OdwMUChanged));
        public DataRow dwMU
        {
            get
            {
                return (DataRow)GetValue(dwMUProperty);
            }
            set
            {
                SetValue(dwMUProperty, value);
                if (value != null)
                {
                    ABAUF = value["ABAAUFKRS"].ToString() + value["ABAAUFLFD"].ToString() + value["ABAAUFPOS"].ToString() + value["ABPPOSTYP"].ToString();
                }
                else
                {
                    ABAUF = "";
                }
            }
        }
        private static void OdwMUChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWDECK;
            if (src != null)
            {
                DataRow row = (DataRow)e.NewValue;
                src.dwMU = row;
            }
        }
        #endregion

        #region ==KDBLOCK===========
        public static readonly DependencyProperty KDBLOCKProperty = DependencyProperty.Register("KDBLOCK",
            typeof(bool), typeof(UIWDECK),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnKDBLOCKChanged));
        public bool KDBLOCK
        {
            get
            {
                return (bool)GetValue(KDBLOCKProperty);
            }
            set
            {
                SetValue(KDBLOCKProperty, value);
                OnKDBLOCKChg(value);

            }
        }
        private static void OnKDBLOCKChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWDECK;
            if (src != null)
            {
                src.KDBLOCK = (bool)e.NewValue;
            }
        }
        public virtual void OnKDBLOCKChg(bool value)
        {


        }
        #endregion

        #region ==IsVKPaid===========
        public static readonly DependencyProperty IsVKPaidProperty = DependencyProperty.Register("IsVKPaid",
            typeof(bool), typeof(UIWDECK),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsVKPaidChanged));
        public bool IsVKPaid
        {
            get
            {
                return (bool)GetValue(IsVKPaidProperty);
            }
            set
            {
                SetValue(IsVKPaidProperty, value);
              
            }
        }
        private static void OnIsVKPaidChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWDECK;
            if (src != null)
            {
                src.IsVKPaid = (bool)e.NewValue;
                src.OnPaidOnly((bool)e.NewValue);
            }
        }
        public virtual void OnPaidOnly(bool value)
        {
        }
        #endregion

        #region ==IsShowAll===========
        public static readonly DependencyProperty IsShowAllProperty = DependencyProperty.Register("IsShowAll",
            typeof(bool), typeof(UIWDECK),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsShowAllChanged));
        public bool IsShowAll
        {
            get
            {
                return (bool)GetValue(IsShowAllProperty);
            }
            set
            {
                SetValue(IsShowAllProperty, value);
                ShowAll();
            }
        }
        private static void OnIsShowAllChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWDECK;
            if (src != null)
            {
                src.IsShowAll = (bool)e.NewValue;
            }
        }
        public virtual void ShowAll()
        {
        }
        #endregion

        #region ==IsVK===========
        public static readonly DependencyProperty IsVKProperty = DependencyProperty.Register("IsVK",
            typeof(bool), typeof(UIWDECK),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsVKChanged));
        public bool IsVK
        {
            get
            {
                return (bool)GetValue(IsVKProperty);
            }
            set
            {
                SetValue(IsVKProperty, value);
            }
        }
        private static void OnIsVKChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWDECK;
            if (src != null)
            {
                src.IsVK = (bool)e.NewValue;
            }
        }
        #endregion

        #region ==IsWZ===========
        public static readonly DependencyProperty IsWZProperty = DependencyProperty.Register("IsWZ",
            typeof(bool), typeof(UIWDECK),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsWZChanged));
        public bool IsWZ
        {
            get
            {
                return (bool)GetValue(IsWZProperty);
            }
            set
            {
                SetValue(IsWZProperty, value);
            }
        }
        private static void OnIsWZChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWDECK;
            if (src != null)
            {
                src.IsWZ = (bool)e.NewValue;
            }
        }
        #endregion

        #region ==IsEK===========
        public static readonly DependencyProperty IsEKProperty = DependencyProperty.Register("IsEK",
            typeof(bool), typeof(UIWDECK),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsEKChanged));
        public bool IsEK
        {
            get
            {
                return (bool)GetValue(IsEKProperty);
            }
            set
            {
                SetValue(IsEKProperty, value);
            }
        }
        private static void OnIsEKChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWDECK;
            if (src != null)
            {
                src.IsEK = (bool)e.NewValue;
            }
        }
        #endregion

        #region ==IsAB===========
        public static readonly DependencyProperty IsABProperty = DependencyProperty.Register("IsAB",
            typeof(bool), typeof(UIWDECK),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsABChanged));
        public bool IsAB
        {
            get
            {
                return (bool)GetValue(IsABProperty);
            }
            set
            {
                SetValue(IsABProperty, value);
                
            }
        }
        private static void OnIsABChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWDECK;
            if (src != null)
            {
                src.IsAB = (bool)e.NewValue;
                src.OnABChg((bool)e.NewValue);
            }
        }
        public virtual void OnABChg(bool _IsAB)
        {
        }
        #endregion

        #region ==IsVV===========
        public static readonly DependencyProperty IsVVProperty = DependencyProperty.Register("IsVV",
            typeof(bool), typeof(UIWDECK),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsVVChanged));
        public bool IsVV
        {
            get
            {
                return (bool)GetValue(IsVVProperty);
            }
            set
            {
                SetValue(IsVVProperty, value);
            }
        }
        private static void OnIsVVChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWDECK;
            if (src != null)
            {
                src.IsVV = (bool)e.NewValue;
            }
        }
        #endregion

        #region ==IsOrder===========
        public static readonly DependencyProperty IsOrderProperty = DependencyProperty.Register("IsOrder",
            typeof(bool), typeof(UIWDECK),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsOrderChanged));
        public bool IsOrder
        {
            get
            {
                return (bool)GetValue(IsOrderProperty);
            }
            set
            {
                SetValue(IsOrderProperty, value);
            }
        }
        private static void OnIsOrderChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWDECK;
            if (src != null)
            {
                src.IsOrder = (bool)e.NewValue;
            }
        }
        #endregion

        #region ==FTMUREV===========
        public static readonly DependencyProperty FTMUREVProperty = DependencyProperty.Register("FTMUREV",
            typeof(bool), typeof(UIWDECK),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnFTMUREVChanged));
        public bool FTMUREV
        {
            get
            {
                return (bool)GetValue(FTMUREVProperty);
            }
            set
            {
                SetValue(FTMUREVProperty, value);
            }
        }
        private static void OnFTMUREVChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWDECK;
            if (src != null)
            {
                src.FTMUREV = (bool)e.NewValue;
            }
        }
        #endregion

        #region ==dwWD===========
        public static readonly DependencyProperty dwWDProperty = DependencyProperty.Register("dwWD",
            typeof(DataRow), typeof(UIWDECK),
            new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OndwWDChanged));
        public DataRow dwWD
        {
            get
            {
                return (DataRow)GetValue(dwWDProperty);
            }
            set
            {
                SetValue(dwWDProperty, value);
            }
        }
        private static void OndwWDChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWDECK;
            if (src != null)
            {
                src.dwWD = (DataRow)e.NewValue;
            }
        }
        #endregion

        #region ==EKAUF===========
        public static readonly DependencyProperty EKAUFProperty = DependencyProperty.Register("EKAUF",
            typeof(string), typeof(UIWDECK),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnEKAUFChanged));
        public string EKAUF
        {
            get
            {
                return (string)GetValue(EKAUFProperty);
            }
            set
            {
                SetValue(EKAUFProperty, value);
            }
        }
        private static void OnEKAUFChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWDECK;
            if (src != null)
            {
                src.EKAUF = (string)e.NewValue;
            }
        }
        #endregion

    
        #region ==TOLOCK===========
        public static readonly DependencyProperty TOLOCKProperty = DependencyProperty.Register("TOLOCK",
            typeof(double), typeof(UIWDECK),
            new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnTOLOCKChanged));
        public double TOLOCK
        {
            get
            {
                return (double)GetValue(TOLOCKProperty);
            }
            set
            {
                SetValue(TOLOCKProperty, value);
            }
        }
        private static void OnTOLOCKChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWDECK;
            if (src != null)
            {
                src.TOLOCK = (double)e.NewValue;
            }
        }
        #endregion


        #region ==AUFART===========
        public static readonly DependencyProperty AUFARTProperty = DependencyProperty.Register("AUFART",
            typeof(string), typeof(UIWDECK),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnAUFARTChanged));
        public string AUFART
        {
            get
            {
                return (string)GetValue(AUFARTProperty);
            }
            set
            {
                SetValue(AUFARTProperty, value);
                
            }
        }
        private static void OnAUFARTChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWDECK;
            if (src != null)
            {
                src.AUFART = (string)e.NewValue;
                src.OnAUFARTChg((string)e.NewValue);
            }
        }
        #endregion

        #region ==BNDABP===========
        public static readonly DependencyProperty BNDABPProperty = DependencyProperty.Register("BNDABP",
            typeof(string), typeof(UIWDECK),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnBNDABPChanged));
        public string BNDABP
        {
            get
            {
                return (string)GetValue(BNDABPProperty);
            }
            set
            {
                SetValue(BNDABPProperty, value); 
            }
        }
        private static void OnBNDABPChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWDECK;
            if (src != null)
            {
                src.BNDABP = (string)e.NewValue;
            }
        }
        #endregion

        #region ==VKK===========
        public static readonly DependencyProperty VKKProperty = DependencyProperty.Register("VKK",
            typeof(string), typeof(UIWDECK),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnVKKChanged));
        public string VKK
        {
            get
            {
                return (string)GetValue(VKKProperty);
            }
            set
            {
                SetValue(VKKProperty, value);
                OnVKKChg(value);
            }
        }
        private static void OnVKKChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWDECK;
            if (src != null)
            {
                src.VKK = (string)e.NewValue;
            }
        }
        #endregion

        #region ==VKBLOCK===========
        public static readonly DependencyProperty VKBLOCKProperty = DependencyProperty.Register("VKBLOCK",
            typeof(string), typeof(UIWDECK),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnVKBLOCKChanged));
        public string VKBLOCK
        {
            get
            {
                return (string)GetValue(VKBLOCKProperty);
            }
            set
            {
                SetValue(VKBLOCKProperty, value);
                OnVKBLOCKChg(value);
            }
        }
        private static void OnVKBLOCKChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWDECK;
            if (src != null)
            {
                src.VKBLOCK = (string)e.NewValue;
            }
        }
        public virtual void OnVKBLOCKChg(string value)
        {
        }
        #endregion

        #region ==PRART===========
        public static readonly DependencyProperty PRARTProperty = DependencyProperty.Register("PRART",
            typeof(string), typeof(UIWDECK),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnPRARTChanged));
        public string PRART
        {
            get
            {
                return (string)GetValue(PRARTProperty);
            }
            set
            {
                SetValue(PRARTProperty, value);
                OnPRARTChg(value);
            }
        }
        private static void OnPRARTChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWDECK;
            if (src != null)
            {
                src.PRART = (string)e.NewValue;
            }
        }
        #endregion

        #region ==RULEKEY===========
        public static readonly DependencyProperty RULEKEYProperty = DependencyProperty.Register("RULEKEY",
            typeof(string), typeof(UIWDECK),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnRULEKEYChanged));
        public string RULEKEY
        {
            get
            {
                return (string)GetValue(RULEKEYProperty);
            }
            set
            {
                SetValue(RULEKEYProperty, value);
                OnRULEKEYChg();
            }
        }
        private static void OnRULEKEYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWDECK;
            if (src != null)
            {
                src.RULEKEY = (string)e.NewValue;
            }
        }
        public virtual void OnRULEKEYChg()
        { }
        #endregion

        #region ==ABKRS===========
        public static readonly DependencyProperty ABKRSProperty = DependencyProperty.Register("ABKRS",
            typeof(string), typeof(UIWDECK),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnABKRSChanged));
        public string ABKRS
        {
            get
            {
                return (string)GetValue(ABKRSProperty);
            }
            set
            {
                SetValue(ABKRSProperty, value);
               
            }
        }
        private static void OnABKRSChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWDECK;
            if (src != null)
            {
                src.ABKRS = (string)e.NewValue;
                src.OnABKRSChg((string)e.NewValue);
            }
        }
        public virtual void OnABKRSChg(string value)
        { }
        #endregion

        #region ==ABKAUFART===========
        public static readonly DependencyProperty ABKAUFARTProperty = DependencyProperty.Register("ABKAUFART",
            typeof(string), typeof(UIWDECK),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnABKAUFARTChanged));
        public string ABKAUFART
        {
            get
            {
                return (string)GetValue(ABKAUFARTProperty);
            }
            set
            {
                SetValue(ABKAUFARTProperty, value);
                OnABKAUFARTChg(value);
            }
        }
        private static void OnABKAUFARTChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWDECK;
            if (src != null)
            {
                src.ABKAUFART = (string)e.NewValue;
            }
        }
        public virtual void OnABKAUFARTChg(string value)
        { }
        #endregion

        #region ==WDTYP===========
        public static readonly DependencyProperty WDTYPProperty = DependencyProperty.Register("WDTYP",
            typeof(string), typeof(UIWDECK),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnWDTYPChanged));
        public string WDTYP
        {
            get
            {
                return (string)GetValue(WDTYPProperty);
            }
            set
            {
                SetValue(WDTYPProperty, value);
                OnWDTYPChg(value);
            }
        }
        private static void OnWDTYPChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWDECK;
            if (src != null)
            {
                src.WDTYP = (string)e.NewValue;
            }
        }
        public virtual void OnWDTYPChg(string value)
        { }
        #endregion

        #region ==WDSA===========
        public static readonly DependencyProperty WDSAProperty = DependencyProperty.Register("WDSA",
            typeof(string), typeof(UIWDECK),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnWDSAChanged));
        public string WDSA
        {
            get
            {
                return (string)GetValue(WDSAProperty);
            }
            set
            {
                SetValue(WDSAProperty, value);
                OnWDSAChg(value);
            }
        }
        private static void OnWDSAChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWDECK;
            if (src != null)
            {
                src.WDSA = (string)e.NewValue;
            }
        }
        public virtual void OnWDSAChg(string value)
        { }
        #endregion
        

        #region ==WZTYP===========
        public static readonly DependencyProperty WZTYPProperty = DependencyProperty.Register("WZTYP",
            typeof(string), typeof(UIWDECK),
            new FrameworkPropertyMetadata("N", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnWZTYPChanged));
        public string WZTYP
        {
            get
            {
                return (string)GetValue(WZTYPProperty);
            }
            set
            {
                SetValue(WZTYPProperty, value);
                OnWZTYPChg(value);
            }
        }
        private static void OnWZTYPChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWDECK;
            if (src != null)
            {
                src.WZTYP = (string)e.NewValue;
            }
        }
        public virtual void OnWZTYPChg(string value)
        { }
        #endregion

        #region ==dwRule===========
        public static readonly DependencyProperty dwRuleProperty = DependencyProperty.Register("dwRule",
        typeof(DataRow), typeof(UIWDECK),
        new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OdwRuleChanged));

        public DataRow dwRule
        {
            get
            {
                return (DataRow)GetValue(dwRuleProperty);
            }
            set
            {
                SetValue(dwRuleProperty, value);
                if (MV == null)
                    return;
                TMV.dwRule = value;
            }
        }
        private static void OdwRuleChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWDECK;
            if (src != null)
            {
                DataRow row = (DataRow)e.NewValue;
                src.dwRule = row;
            }
        }
        #endregion

        #region ==WZCMD===========
        public static readonly DependencyProperty WZCMDProperty = DependencyProperty.Register("WZCMD",
            typeof(string), typeof(UIWDECK),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnWZCMDChanged));
        public string WZCMD
        {
            get
            {
                return (string)GetValue(WZCMDProperty);
            }
            set
            {
                SetValue(WZCMDProperty, value);
                OnWZCMDChg();
            }
        }
        private static void OnWZCMDChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWDECK;
            if (src != null)
            {
                src.WZCMD = (string)e.NewValue;
            }
        }
        public virtual void OnWZCMDChg()
        { }
        #endregion
    }
}
